﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GLYFrom.DDGL
{
    public partial class DD_update : Form
    {
        public DD_update()
        {
            InitializeComponent();
        }
        int id = 0;
        public DD_update(int a)
        {
            id = a;
            InitializeComponent();
        }

        private void DD_update_Load(object sender, EventArgs e)
        {
            DataTable table = DBHelper.select(string.Format("select * from T_DingDan where DDid='{0}'",id));
            DataRow row = table.Rows[0];
            this.text_Id.Text = row["YHId"].ToString();
            this.text_DDH.Text = row["DDH"].ToString();
            this.text_Name.Text = row["CPName"].ToString();
            this.text_Time.Text = row["time"].ToString();
            this.text_JiaGe.Text = row["JiaGe"].ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string YHId = this.text_Id.Text.Trim();
            string DDH = this.text_DDH.Text.Trim();
            string Name = this.text_Name.Text.Trim();
            string Time = this.text_Time.Text.Trim();
            string JiaGe = this.text_JiaGe.Text.Trim();
            if (YHId.Length > 0 && DDH.Length > 0 && Name.Length > 0 && Time.Length > 0 && JiaGe.Length > 0)
            {
                int sr = DBHelper.ZSG(string.Format("update T_DingDan set YHId='{0}',DDH='{1}',CPName='{2}',time='{3}',JiaGe='{4}' where DDId='{5}'", YHId, DDH, Name, Time, JiaGe,id));
                if (sr > 0)
                {
                    MessageBox.Show("修改成功！");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("修改失败！");
                }
            }
            else
            {
                MessageBox.Show("修改失败，请填写完整！");
            }
        }
    }
}
